package top.xia17.plugins.fast.common.database.jpa.extension;

import jakarta.transaction.Transactional;

import java.util.Collection;

/**
 * 基础service实现
 * create update delete 添加事务注解
 * @author xia17
 */
public class JpaTxServiceImpl<T extends JpaEntity<ID>, ID, R extends Xia17JpaRepository<T, ID>> extends JpaServiceImpl<T,ID,R> {


    @Override
    @Transactional(rollbackOn = Exception.class)
    public T create(T resource) {
        return super.create(resource);
    }

    @Override
    @Transactional(rollbackOn = Exception.class)
    public T update(T resource) {
        return super.update(resource);
    }

    @Override
    @Transactional(rollbackOn = Exception.class)
    public void deleteById(ID id) {
        super.deleteById(id);
    }

    @Override
    @Transactional(rollbackOn = Exception.class)
    public void deleteById(Collection<ID> ids) {
        super.deleteById(ids);
    }
}
